<template>
	<view class="news">
		<news-item :news="news" @itemClick="goDetail"></news-item>
	</view>
</template>

<script>
	import newsItem from '../components/news-item/news-item.vue'
	export default {
		data() {
			return {
				news:[]
			}
		},
		onLoad() {
			this.getNews()
		},
		methods: {
			async getNews(){
				const news = await this.$myRequest({
					url:'/api/getNews.json'
				})
				this.news = news.data.message
			},
			goDetail(newsId){//跳转到详情页面
				uni.navigateTo({
					url:'/pages/news-detail/news-detail'
				})
			}
		},
		components:{
			"news-item":newsItem
		}
	}
</script>
	
<style lang="scss">
</style>
